package fun.wlfj.j2t.model;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Method extends Element {
	
	public List<Element> paramList = new ArrayList<>();
	public Element returnType;
	
	public Method(String name, Element returnType, Element... params) {
		super(name);
		this.returnType = returnType;
		this.paramList.addAll(List.of(params));
	}

	public String strRepr() {
		// getB(int, int): int
		String args = 
				paramList.stream().map(e -> e.name)
				.collect(Collectors.joining(", "));
		return name + "(" + args + "): " + returnType.name;
	}
}
